package com.kuyun.service.impl;

import java.util.HashMap;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kuyun.entity.FunsType;
import com.kuyun.mapper.FunsTypeMapper;
import com.kuyun.service.FunsTypeService;

@Service
public class FunsTypeServiceImpl implements FunsTypeService {

	@Autowired
	private FunsTypeMapper funsTypeMapper;

	// 查询所有趣事类型
	public List<FunsType> findAllFunsType() {
		// TODO Auto-generated method stub
		try {
			return funsTypeMapper.findAllFunsType();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	// 查询单个趣事类型
	public FunsType findFunsType(Integer id) {
		// TODO Auto-generated method stub
		try {
			return funsTypeMapper.findFunsType(id);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	// 查询是否存在趣事类型名称
	public FunsType compareFunsType(String type) {
		// TODO Auto-generated method stub
		try {
			return funsTypeMapper.compareFunsType(type);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	// 删除单个趣事类型
	public boolean delFunsType(Integer id) {
		try {
			return funsTypeMapper.delFunsType(id) >= 1 ? true : false;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	// 删除部分趣事类型
	public boolean delSomeFunsType(String idStr) {
		idStr = idStr.substring(0, idStr.length() - 1);
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("idStr", idStr);
		try {
			return funsTypeMapper.delSomeFunsType(paramMap) >= 1 ? true : false;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	// 增加单个趣事类型
	public boolean insFunsType(FunsType funsType) {
		try {
			return funsTypeMapper.insFunsType(funsType) >= 1 ? true : false;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	// 修改单个趣事类型
	public boolean queryFunsType(FunsType funsType) {
		try {
			return funsTypeMapper.queryFunsType(funsType) >= 1 ? true : false;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

}
